<!-- 我的统计 -->

<template>
  <div class="SecureStatistic SecureStatistic-col2">
    <div>
      <MajorTitle title="违规类型" />

      <div>
        <TypeChart v-bind="info.type" />
      </div>
    </div>

    <div>
      <MajorTitle title="累计次数">
        <template #right>
          <ParamRadio :param="infoParam" bind="type" :dict="DICT.DATE" isBtn @change="changeType" />
        </template>
      </MajorTitle>

      <div>
        <TopRank :top="10" empty="暂无违规" />
      </div>
    </div>
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyStatistic',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb(), CORE.mixInfo()],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(
    require.context('../../../components', true, /vue$/),
    require.context('./', true, /vue$/),
  ),

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 切换类型
     */
    changeType(type) {
      let startTime
      if (type === 1) startTime = CORE.timeNum(CORE.today()) // 今天 00:00:00
      else if (type === 2) startTime = CORE.timeNum(CORE.weekMonday(CORE.today())) // 周一 00:00:00
      else startTime = CORE.timeNum(CORE.today().slice(0, 7)) // 月初 00:00:00

      const endTime = CORE.timeNum(CORE.today(1), -1) // 今天 23:59:59

      Object.assign(this.infoParam, { startTime, endTime })

      this.startInfo()
    },
  },
}
</script>

<style lang="scss">
@import '@admin/views/Secure/Track/TrackStatistic/MyStatistic/index.scss';
</style>
